package com.zyht.website.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zyht.common.AbsBaseController;
 
@Controller
@RequestMapping("/anon")
public class AnonController extends AbsBaseController{
	
	@RequestMapping("/index")
	public @ResponseBody String index(HttpServletRequest request, Model m) {
		return "错误消息";
	}
	
	@RequestMapping("out")
	public String timeOut(Model model){
		model.addAttribute("error","页面已超时");
		return "basic/shared/error";
	}
	
	/**
	 * <b>作者:</b> zrb<br/>
	 * <b>修改时间：</b>2016年4月20日 - 上午11:19:22<br/>
	 * <b>功能说明：</b>集中处理404	<br/>
	 * @return
	 */
	@RequestMapping("404")
	public String pageNotFound(){
		return "404";
	}
	
	/**
	 * <b>作者:</b> zrb<br/>
	 * <b>修改时间：</b>2016年4月20日 - 上午11:19:22<br/>
	 * <b>功能说明：</b>集中处理500	<br/>
	 * @return
	 */
	@RequestMapping("500")
	public String sysError(){
		return "500";
	}
	
	@RequestMapping("error")
	public String requestDeny(Model model){
		model.addAttribute("msg", "用户无权访问");
		model.addAttribute("redirect", "admin/index");
		return "message";
	}
	
	@RequestMapping("msg")
	public String msg( 
			@RequestParam(value = "msg", required = false) final String msg,
			@RequestParam(value = "redirect", required = false) final String redirect,
			Model model){
		model.addAttribute("msg", msg);
		model.addAttribute("redirect", redirect);
		return "admin/msg";
	}
	
	@RequestMapping("fail")
	public String requestFail(Model model){
		model.addAttribute("msg", "用户无权操作");
		model.addAttribute("redirect", "admin/index");
		return "message";
	}
}
